﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

using HeinQi.Framework;

namespace TbShop.Web.Infrastructure
{
    public class HandleErrorLogAttribute : FilterAttribute, IExceptionFilter
    {
        public virtual void OnException(ExceptionContext filterContext)
        {
            var message = string.Format("消息类型：{0}\n消息内容：{1}\n引发异常的方法：{2}\n引发异常源：{3}"
                , filterContext.Exception.GetType().Name
                , filterContext.Exception.Message
                 , filterContext.Exception.TargetSite
                 , filterContext.Exception.Source + filterContext.Exception.StackTrace
                 );

            HeinQi.Framework.Common.LogHelper.Log.Error(message);
        }
    }
}
